package com.geoway.adf.report.controller;

import com.geoway.adf.report.excel.sheet.Sheet;
import com.geoway.adf.report.po.SheetPO;
import com.geoway.adf.report.service.SheetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: lzw
 * @Date: 2024/1/18 14:48
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping(value = "/sheet", produces = {"application/json;charset=UTF-8" })
public class SheetController {
    @Autowired
    private SheetService sheetService;

    @GetMapping("/findById")
    public Sheet findById(String id){
        return sheetService.findById(id).orElse(new SheetPO()).getSheet();
    }

    @PostMapping("/save")
    public SheetPO save(@RequestBody Sheet sheet,@RequestParam String workbookId){
        return sheetService.save(SheetPO.toSheetPO(sheet,workbookId));
    }
}
